package holder;

import base.BaseHolder;
import bean.AppInfoBean;

import com.example.googlemarketdemo.R;
import com.lidroid.xutils.BitmapUtils;

import conf.constants.URLS;

import utils.BitmapHepler;
import utils.StringUtils;
import utils.UIUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

/**
 * 提供视图
 * 接收数据
 * 内部让数据和视图绑定
 * @author Anson-pc
 *
 */
public class AppHolder extends BaseHolder<AppInfoBean>{
	private TextView tvTmp1;
	private TextView tvTmp2;
	private ImageView mIvIcon;
	private RatingBar mRbStars;
	private TextView mTvDes;
	private TextView mTvSize;
	private TextView mTvTitle;

	//视图
	@Override
	protected View initHolderView() {
		View rootView = View.inflate(UIUtils.getContext(), R.layout.item_home_info,null);
		mIvIcon = (ImageView) rootView.findViewById(R.id.item_appinfo_iv_icon);
		mRbStars = (RatingBar) rootView.findViewById(R.id.item_appinfo_rb_stars);
		mTvDes = (TextView) rootView.findViewById(R.id.item_appinfo_tv_des);
		mTvSize = (TextView) rootView.findViewById(R.id.item_appinfo_tv_size);
		mTvTitle = (TextView) rootView.findViewById(R.id.item_appinfo_tv_title);
		
		return rootView;
	}

	//视图绑定数据
	@Override
	protected void refreshHolderView(AppInfoBean data) {
		mTvDes.setText(data.des);
		mTvSize.setText(StringUtils.formatFileSize(data.size));
		mTvTitle.setText(data.name);
		mRbStars.setRating(data.stars);
		mIvIcon.setImageResource(R.drawable.ic_default);
		//图片的加载
//		BitmapUtils bitmapUtils = new BitmapUtils(UIUtils.getContext());
		System.out.println(URLS.IMAGEBASEURL+data.iconUrl);
		BitmapHepler.display(mIvIcon, URLS.IMAGEBASEURL+data.iconUrl);
	}
	
	
}
